﻿@model Webs.Models.BillModel
@if (ViewBag.ErrMsg != null)
{
    <div id="dErrMsg" class="ui-state-error ui-corner-all" style="margin-top: 5px; padding: 5px;
        font-size: .9em;">
        <p style="vertical-align: top; margin: 0; padding: 0;">
            <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
            <strong>@ViewBag.ErrMsg</strong>
        </p>
        <div style="margin-left: 23px;">@Html.ValidationSummary(false, "Please correct the errors and try again:")</div>
    </div>
}
@if (ViewBag.SuccMsg != null)
{
    <div id="dSuccMsg" class="ui-state-highlight ui-corner-all" style="margin-top: 5px;
        padding: 5px; font-size: .9em;">
        <p style="vertical-align: top; margin: 0; padding: 0;">
            <span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
            <strong>@ViewBag.SuccMsg</strong>
        </p>
    </div>
}
<div id="tabs">
    @Html.HiddenFor(m => m.BillNo, new { id = "hBillNo" })
    <ul>
        <li><a href="#Infomation">@BillRes.BillString.Infomation</a></li>
        <li><a href="#Particular">@BillRes.BillString.Particular</a></li>
        <li><a href="#Payment">@BillRes.BillString.Payment</a></li>
        <li><a href="#Receipt">@BillRes.BillString.Receipt</a></li>
    </ul>
    <div id="@BillRes.BillString.Infomation">
        <table border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td width="460px" valign="top">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.SHIPPEREXPORTER
                                </div>
                                <div class="editor-field">
                                    @Html.TextAreaFor(m => m.Shipper, new { Class = "editor-field-col", style = "width:415px" })
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.CONSIGNEE
                                </div>
                                <div class="editor-field">
                                    @Html.TextAreaFor(m => m.Consignee, new { Class = "editor-field-col", style = "width:415px" })
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.NOTIFYPARTY
                                </div>
                                <div class="editor-field">
                                    @Html.TextAreaFor(m => m.NotifyParty, new { Class = "editor-field-col", style = "width:415px" })
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
                <td valign="top">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="220px">
                                <div class="editor-label">
                                    @BillRes.BillString.BOOKINGNO&nbsp;<span class="msgErr">*&nbsp;<span id="errBookingNo"></span></span>
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.BookingNo, new { Class = "editor-field-col" })
                                </div>
                            </td>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.BILLOFLOADINGNO&nbsp;<span class="msgErr">*&nbsp;<span id="errBillOfLoadingNo"></span></span>
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.BillOfLoadingNo, new { Class = "editor-field-col" })
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <div class="editor-label">
                                    @BillRes.BillString.DELIVERYAGENT
                                </div>
                                <div class="editor-field">
                                    @Html.TextAreaFor(m => m.DeliveryAgent, new { Class = "editor-field-col", style = "width:415px" })
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.PRECARRIAGEBY
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.PreCarriageBy, new { Class = "editor-field-col" })
                                </div>
                            </td>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.PLACEOFRECEIPT
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.PlaceOfReceipt, new { Class = "editor-field-col" })
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.OCEANVESSELVOYAGENO
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.OceanVessel, new { Class = "editor-field-col" })
                                </div>
                            </td>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.PORTOFLOADING
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.PortOfLoading, new { Class = "editor-field-col" })
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.PORTOFDISCHARGE
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.PortOfDischarge, new { Class = "editor-field-col" })
                                </div>
                            </td>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.PLACEOFDELIVERY
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.PlaceOfDelivery, new { Class = "editor-field-col" })
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="editor-label">
                        @BillRes.BillString.FINALDESTINATION
                    </div>
                    <div class="editor-field">
                        @Html.TextBoxFor(m => m.FinalDestination, new { Class = "editor-field-col", style = "width:330px" })
                    </div>
                </td>
                <td>
                    <div class="editor-label">
                        @BillRes.BillString.TYPEOFMOVEMENT
                    </div>
                    <div class="editor-field">
                        @Html.TextBoxFor(m => m.TypeOfMovement, new { Class = "editor-field-col", style = "width:330px" })
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="220px">
                                <div class="editor-label">
                                    @BillRes.BillString.FREIGHTCHARGESPAYABLEAT
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.FreightAndCharge, new { Class = "editor-field-col" })
                                </div>
                            </td>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.SERVICECOTRACTNO
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.ServiceContractNo, new { Class = "editor-field-col" })
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.EXCHANGERATE
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.ExchangeRate, new { Class = "editor-field-col" })
                                </div>
                            </td>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.DATELADENONBOARD
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.DateLadenOnBoard, new { Class = "editor-field-col" })
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="240px">
                                <div class="editor-label">
                                    @BillRes.BillString.NUMBEROFORIGINAL
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.NumberOfOriginal, new { Class = "editor-field-col" })
                                </div>
                            </td>
                            <td>
                                <div class="editor-label">
                                    @BillRes.BillString.COMMODITYCODE
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.CommodityCode, new { Class = "editor-field-col" })
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td width="240px">
                                <div class="editor-label">
                                    @BillRes.BillString.PLACEANDDATEOFISSUE
                                </div>
                                <div class="editor-field">
                                    @Html.TextBoxFor(m => m.PlaceDateOfIssue, new { Class = "editor-field-col" })
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="editor-label">
                        <input type="submit" id="btnSubmit" class="btn" value="@SharedRes.SharedString.Save" />
                        @if (Model != null)
                        {
                            <input type="button" id="lnkDelete" class="btn" value="@SharedRes.SharedString.Delete" style="margin-left: 5px" />
                            <input type="button" id="lnkClone" class="btn" value="@SharedRes.SharedString.Clone" style="margin-left: 5px" />
                            <input type="button" id="lnkPrint" class="btn" value="@SharedRes.SharedString.Print" style="margin-left: 5px" />
                        }
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div id="@BillRes.BillString.Particular">
        @if (Model != null)
        {
            @Html.Action("BillDetail", "Bill")
        }
    </div>
    <div id="@BillRes.BillString.Payment">
        @if (Model != null)
        {
            @Html.Action("BillPayment", "Payment")
            <a href='@Url.Action("Add", "Payment", new { id = @ViewBag.BillNo }) ' class="lnkBtn" style="margin-top: 5px">
                @SharedRes.SharedString.Add
            </a>
        }
    </div>
    <div id="@BillRes.BillString.Receipt">
        @if (Model != null)
        {
            @Html.Action("BillReceipt", "Receipt")
            <a href='@Url.Action("Add", "Receipt", new { id = @ViewBag.BillNo }) ' class="lnkBtn" style="margin-top: 5px">
                @SharedRes.SharedString.Add
            </a>
        }
    </div>
</div>
@if (@Model != null)
{
    <div id="dPrint">
        @Html.Partial("_PrintOption")
    </div>
    <div id="dConfirm">
        @MvcHtmlString.Create(SharedRes.SharedString.ConfirmDelete)
    </div>
    
    <script type="text/javascript">
        $(document).ready(function () {

            $("#dPrint").dialog({
                autoOpen: false,
                title: "@SharedRes.SharedString.PrintOption",
                width: 240,
                height: 160,
                modal: true,
                resizable: false,
                buttons: [{
                    text: "@SharedRes.SharedString.Print",
                    click: function () {
                        $(this).dialog("close");
                        if ($(chkOption).is(':checked'))
                            window.open('@Url.Action("Print", "Bill", new { id = Model.BillNo, layout = false })');
                        else
                            window.open('@Url.Action("Print", "Bill", new { id = Model.BillNo, layout = true })');
                    }
                }, {
                    text: "Cancel",
                    click: function () {
                        $(this).dialog("close");
                    }
                }]
            });

            $('#lnkPrint').click(function () {
                $('#dPrint').dialog('open');
                return false;
            });

            $("#dConfirm").dialog({
                autoOpen: false,
                title: "Confirm",
                width: 240,
                height: 160,
                modal: true,
                resizable: false,
                buttons: [{
                    text: "@SharedRes.SharedString.Delete",
                    click: function () {
                        $(this).dialog("close");
                        window.location = '@Url.Action("Delete", "Bill", new { id = Model.BillNo })';
                    }
                }, {
                    text: "Cancel",
                    click: function () {
                        $(this).dialog("close");
                    }
                }]

            });

            $('#lnkDelete').click(function () {
                $('#dConfirm').dialog('open');
                return false;
            });

            $('#lnkClone').click(function () {
                window.location = '@Url.Action("Clone", "Bill", new { id = Model.BillNo })';
                return false;
            });

        });
    </script>

}
<script type="text/javascript">
    $(document).ready(function () {
        $("#tabs").tabs();

        $("#btnSubmit").click(function () {
            $("#errBookingNo").html("");
            $("#errBillOfLoadingNo").html("");
            $("#BookingNo").removeClass("input-validation-error");
            $("#BillOfLoadingNo").removeClass("input-validation-error");

            if ($("#BookingNo").val() == "") {
                $("#errBookingNo").html("@SharedRes.SharedString.IsRequired");
                $("#BookingNo").addClass("input-validation-error");
                return false;
            }
            if ($("#BillOfLoadingNo").val() == "") {
                $("#errBillOfLoadingNo").html("@SharedRes.SharedString.IsRequired");
                $("#BillOfLoadingNo").addClass("input-validation-error");
                return false;
            }

            return true;
        });
    });
</script>
